<template>
  <div>
    <div>
      <ele-table
        v-loading="loading"
        ref="eleTable"
        :column="column"
        :getList="getDictList"
        uniqueId="repairItemTable"
        :pagination="false"
      ></ele-table>
    </div>
    <userGroup
      :isShowDialog="groupDialogOpen"
      :userGroupData="userGroupData"
      @closeGroupDialog="closeGroupDialog"
    ></userGroup>
  </div>
</template>

<script>
import { operateList, rowConfig } from './config'


import {getDictList,queryIdGroup} from '@/api/typeRecheckProject/typeRecheckProject'
import userGroup from '@/views/recheckProject/typeRecheckProject/userGroup.vue'

export default {
  name: 'typeRecheckProject',
  components: {
    userGroup
  },
  data() {
    const self = this
    return {
      userGroupData:{
        rowId: '',
        rowName:'',
        groupIds: ['1796433831987081217']
      },
      groupDialogOpen: false,
      title: null,
      loading: false,
      getDictList,

      operateList,
      // 列表页字段的绑定配置
      column: [
        {
          type: 'index',
          label: $i18n.t('common.order'),
          width: 60,
          fixed: 'left'
        },
        {
          prop: 'description',
          label: '复检项',
          showOverflowTooltip: true
        },
        {
          prop: 'operate',
          label: $i18n.t('common.operation'),
          width: 160,
          fixed: 'right',
          render: (h, scope) => {
            return <ele-row-operation scope={scope} rowConfig={rowConfig} onRowOperate={this.rowOperate} />
          }
        }
      ]
    }
  },
  computed: {},
  methods: {
    closeGroupDialog(){
      this.groupDialogOpen = false
    },
    // 表格行操作事件
    rowOperate({ handleName, name, row }) {
      this.title = name
      const fnc = {
        edit: () => {
          this.userGroupData.rowId = row.id
          this.userGroupData.rowName = row.description
          queryIdGroup(row.id).then(res=>{
            this.userGroupData.groupIds =  res.data.result
          })
          this.groupDialogOpen = true
        }
      }
      fnc[handleName]()
    },
    // 刷新表格数据
    refresh(isReset = true) {
      this.$refs.eleTable.refresh(isReset)
    }
  }
}
</script>
